'use strict';

const Controller = require('egg').Controller;

class ListController extends Controller {
  async findPage() {
    // const { ctx } = this.ctx.service.ListController;
    const data = await this.ctx.service.list.queryList(this.ctx.request.body);

    // console.log(body)
    this.ctx.body =  {
        returnCode:0,
        bean:{
            total:2
        },
        beans:[ {
            id:'131313',
            rolename: '李四',
            username: 'huang',
            email: '123@qq.com',
            telphone: '18638281552'
         },
         {
            id:'131313',
            rolename: '张三',
            username: 'username',
            email: '12313213@qq.com',
            telphone: '18638281552'
         },],
        ...data
    }
  }
  async queryAllList(){
      const data = await this.ctx.service.list.queryAllList();
      console.log('queryAllList===',queryAllList)
      this.ctx.body = {
        returnCode:0,
        bean:{
            total:data.length
        },
        beans:[...data],
        
    };
  }
  async addItem(){
    try {
      const data = await this.ctx.service.list.addItem(this.ctx.request.body);
      if(data){
        this.ctx.body = {
          returnCode:0,
          returnMsg:'添加成功'
        };
      }
       
    } catch (error) {
      
    }
  
  }
}

module.exports = ListController;
